package py.com.alfa.escriba.util;

import java.text.SimpleDateFormat;

import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;

import org.codehaus.jackson.map.ObjectMapper;

@Provider
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class JacksonConfig implements ContextResolver<ObjectMapper> {

  public static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
  private ObjectMapper mapper = new ObjectMapper();

  public JacksonConfig()
  {
    mapper.setDateFormat(new SimpleDateFormat(DATE_FORMAT));
  }

  @Override
  public ObjectMapper getContext(Class<?> arg0) {
      return mapper;
  }
}